<?php

namespace app\shop\controller;

use buildView\Actions;
use buildView\Button;
use think\Console;
use think\Controller;
use buildView\Form;
use buildView\Grid;
use app\shop\model\ShopBanner;

/**
 * 轮播图
 * Class Banner
 * @package app\admin\controller
 */
class Banner extends Controller
{
    /**
     * 列表
     * @auth true
     * @mentu true
     * @return string
     */
    public function index()
    {
        $grid = new Grid(new ShopBanner);
        $grid->setTitle('轮播图');
        $grid->model()->order('sort asc,id desc');
        $grid->title('广告图标题');
        $grid->img_url('广告图图片')->image(0, 200, 80);
        $grid->page_url('跳转路径');
        $grid->good()->title('跳转商品名称');
        $grid->status('是否显示')->switchs();
        $grid->create_at('创建时间');
        $grid->hideExportButton();
        $grid->setFromOpen();
        $grid->actions(function (Actions $action) {
            $action->hideDetail();
        });

        return $grid->view();
    }

    /**
     * 添加/编辑
     * @auth true
     * @mentu true
     * @return string
     */
    public function form()
    {
        $form = new Form(new ShopBanner);
		$form->text('title','广告图标题')->required();
		$form->text('page_url','广告图标题')->required();
		$form->image('img_url','广告图图片')->required()->help('建议图片尺寸700 * 260');
        return $form->view();
    }
}
